﻿#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include "SequenceStackStore.h"

struct PersonStack
{
	char name[64];
	int age;
};

void testSeqStack()
{
	//11.初始化栈；
	SeqStack stack = Init_SeqStack();

	//12.创建数据；
	struct PersonStack p1 = { "aaa",10 };
	struct PersonStack p2 = { "bbb",20 };
	struct PersonStack p3 = { "ccc",30 };
	struct PersonStack p4 = { "ddd",40 };
	struct PersonStack p5 = { "eee",50 };

	//13.数据入栈；
	Push_SeqStack(stack, &p1);
	Push_SeqStack(stack, &p2);
	Push_SeqStack(stack, &p3);
	Push_SeqStack(stack, &p4);
	Push_SeqStack(stack, &p5);

	//14.输出栈中所有的元素；
	while (Size_SeqStack(stack) > 0)
	{
		//15.获取栈顶元素；
		struct PersonStack* person = (struct PersonStack*)Top_SeqStack(stack);
		//16.打印输出元素；
		printf("17.输出栈中的顶元素person为Name：%s  Age：%d\n", person->name, person->age);//50,40,30,20,10
		//19.弹出栈顶元素；
		Pop_SeqStack(stack);
	}

	printf("20.输出栈的大小Size：%d\n", Size_SeqStack(stack));//0

	//18.销毁栈；
	Destroy_SeqStack(stack);
	stack = NULL;
}

//main224：栈的顺序存储
int main224()
{
	testSeqStack();

	system("pause");
	return EXIT_SUCCESS;
}